<template>
	<page>
		<view class='explain' v-if="type==0">
			<view><text>以下用户未完成：入驻个人资料填写。</text></view>
			<view><text>请再邀请他，或联系他完善入驻资料。</text></view>
		</view>
		<view class='explain' v-if="type==1">
			<view><text>同城共享装修：装修业务信息共享！</text></view>
			<view><text>施工队满100人送会员1年，满300人永久免费。</text></view>
		</view>
		<block v-if="lists.length != 0">
			<view class='weui-cells'>
				<view class='weui-cell' v-for="(item,index) in lists" :data-id="item.id" @tap='goCard'>
					<view class='weui-cell__hd dp-flex-y-center'>
						<image :src="item.newAvatarUrl||item.avatarUrl"></image>
					</view>
					<view class='weui-cell__bd' v-if="item.name || item.nickName">{{item.name ? item.name : item.nickName}}</view>
					<view class='weui-cell__bd' wx:else>此用户未填写入驻资料</view>
					<view class='weui-cell__ft'>{{item.created_at}}</view>
				</view>
			</view>
		</block>
		<block v-else>
			<view class='no-result dp-flex-xy-center'>暂时没有邀请数据</view>
		</block>
	</page>
</template>

<script>
	import app from '@/App.vue';
	import {
		GYZJMODEL as gyzjModel
	} from '@/utils/gyzjModel.js'
	export default {
		onLoad(options) {
			/*设置type的值*/
			this.type = options.type;
			let arr = this.main_getGlobal();
			if (options.type) {
				if (options.type == '0') {
					uni.setNavigationBarTitle({
						title: '邀请中的好友'
					})
				} else if (options.type == '1') {
					uni.setNavigationBarTitle({
						title: '已入驻成功的好友'
					})
				} else {
					uni.setNavigationBarTitle({
						title: '已开通会员'
					})
				}
				let loadMore = false;
				this.getMySubordinate(options.type, loadMore, arr.token, arr.type);
			}
		},
		data() {
			return {
				lists: [],
				status: {},
				page: 1,
				pageCount: 1,
				active: 0,
				type: '',
			}
		},
		methods: {
			
			/*获取邀请的人数*/
			getMySubordinate: function(cat, loadMore, token, type) {
				uni.showLoading({
					title: '加载中...',
				})
				/*实际传参loadMore是没有的*/
				gyzjModel.prototype.getMySubordinate(cat,token, type).then(res => {
					console.log('进来获取res', res);
					switch (res.code) {
						case 1:
							uni.hideLoading();
							let page = res.data.page;
							let pageCount = res.data.pageCount;
							let lists = res.data.data;
							/*进行追加数据*/
							if (loadMore) {
								lists = this.lists.concat(res.data.data);
							}
							console.log('lists的值', lists);
							this.lists = lists;
							this.status = res.data.countArr;
							this.page = res.data.page_count;
							this.pageCount = res.data.total_count;

							break;
						default:
							console.log('进来默认执行');
							uni.hideLoading();
							uni.showToast({
								title: res.message,
								icon: 'none'
							});
							break;
					}
				})
			},
			//我发布的点击跳转名片
			goCard: function(e) {
				console.log(e);
				var id = e.currentTarget.dataset.id;
				wx.navigateTo({
					url: '../my-info/cardcase/cardcase?id='+id+'&free=my-invite-list',
				})
			},
		}
	}
</script>

<style>
	@import url("../../../static/style/app.css");
	page {
		background-color: #fff;
	}

	.weui-cells {
		margin-top: 0upx;
	}

	.weui-cell__hd image {
		border-radius: 50%;
		width: 60upx;
		height: 60upx;
		margin-right: 20upx;
	}

	.no-result {
		margin: 150upx;
		color: #666;
		text-align: center;
	}

	.top-fixed {
		position: fixed;
		top: 0;
		width: 100%;
		background-color: #fff;
		border-bottom: 1px solid #e5e5e5;
		z-index: 5;
	}

	.fixed-wrap {
		height: 100upx;
	}

	.fixed-item {
		width: 100%;
		text-align: center;
		border-right: 1px solid #e5e5e5;
	}

	.border-0 {
		border-right: 0;
	}

	.num {
		position: relative;
		bottom: 10upx;
		height: 20upx;
		color: #888;
	}

	.active {
		color: #f94c48;
	}

	/* 邀请的人说明 */
	.explain {
		height: 100upx;
		background-color: #CCCCCC;
	}

	.explain view {

		text-align: center;
	}

	.explain view text {
		font-size: 33upx;
		/* font-weight: bold; */

	}
</style>
